﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CBTM.Model
{

    public class TTable : IDictionary
    {
        private DictionaryEntry[] entries;
        private Int32 count;

        public TTable(int quantity)
        {
            entries = new DictionaryEntry[quantity];
        }

        #region IDictionary Members

        public bool Contains(string key)
        {
            string index;
            return TryGetIndex(key, out index);
        }
        public void Remove(string key)
        {
            if (key == null)
                throw new ArgumentNullException("Input key is null");
            int index;
            if (TryGetIndex(key, out index))
            {
                Array.Copy(entries, index + 1, entries, index, count - index - 1);
                count--;
            }
            else
            {

            }
        }
        public void Clear() { count = 0; }
        public void Add(string key, string value)
        {
            if (count == entries.Length)
                throw new InvalidOperationException("Cannot add more entries");
            entries[count++] = new DictionaryEntry(key, value);
        }
        public ICollection Keys
        {
            get
            {
                object[] keys = new object[count];
                for (int i = 0; i < count; i++)
                    keys[i] = entries[i].Key;
                return keys;
            }
        }
        public bool TryGetIndex(string key, out int index)
        {
            index = 0;
            return 0;
        }
        public bool TryGetValue(string key, out string value)
        {
            value = "";
            return true;
        }
        #endregion
    }
}
